

#ifndef __CE_GFX_IDEVICE_H__
#define __CE_GFX_IDEVICE_H__

#include <export.h>
#include <ifile.h>
#include <gfx/enum.h>
#include <math/color.h>
#include <string>



class  ceBoundingBox;
class  ceCamera;
struct ceCapabilities;
class  ceProjector;
class ceLight;
class  ceMaterial;
struct ceMaterialSpec;
struct ceMatrix4f;
struct ceRect;
struct ceRenderTargetDescriptor;
class  ceSharedShaderBinding;
struct ceTextureDescriptor;
struct ceVertexElement;

struct iBillboardMesh;
struct iEffect;
struct iEffectTechnique;
struct iFile;
struct iIndexBuffer;
struct iInstancedMesh;
struct iMorphMesh;
struct iPatchMesh;
struct iProgram;
struct iRenderTarget;
struct iShader;
struct iSkinMesh;
struct iStaticMesh;
struct iTexture;
struct iTexture2D;
struct iVertexBuffer;
struct iVertexDeclaration;
struct iViewport;

/**
 * \addtogroup graphics
 * @{
 */

/**
 * @brief Interface for the communication and manipulation of a hardware rendering device.
 */
struct CE_API iDevice
{

  virtual const ceCapabilities& GetCapabilities () = 0;

  virtual void DebugStats () = 0;

  virtual bool IsCapable () = 0;

  virtual bool CheckShadingVersion (unsigned version) = 0;
  virtual bool CheckExtension (const char* extension) = 0;

  /**
   * \name Creation methods
   * @{
   */

  virtual ceRef<iVertexBuffer> CreateVertexBuffer (unsigned size, const void* data, ceBufferDataMode mode) = 0;
  virtual ceRef<iIndexBuffer> CreateIndexBuffer (unsigned size, const void* data, ceBufferDataMode mode) = 0;
  virtual ceRef<iVertexDeclaration> CreateVertexDeclaration (const ceVertexElement* elements) = 0;



  virtual iTexture2D* CreateTexture2D (const ceTextureDescriptor& desc) = 0;
  virtual iRenderTarget* CreateRenderTarget (const ceRenderTargetDescriptor& desc) = 0;

  virtual ceRef<iShader> CreateShader (ceShaderType type) const = 0;
  virtual ceRef<iEffect> CreateEffect () = 0;
	virtual ceRef<iEffectTechnique> CreateEffectProgram () = 0;
  virtual ceRef<iProgram> CreateProgram () = 0;
  /**
   * @}
   */

  /**
   * \name Functions for creating meshes
   * @{
   */
  virtual iBillboardMesh* CreateBillboardMesh () = 0;
  virtual iInstancedMesh* CreateInstancedMesh () = 0;
  virtual iMorphMesh* CreateMorphMesh () = 0;
  virtual iPatchMesh* CreatePatchMesh () = 0;
  virtual iSkinMesh* CreateSkinMesh () = 0;
  virtual iStaticMesh* CreateStaticMesh () = 0;
  /**
   * @}
   */


  /**
   * \name Defaults
   * @{
   */
  virtual void SetDefaultAnisotropic (unsigned anisotropic) = 0;
  virtual unsigned GetDefaultAnisotropic () const = 0;

  virtual void SetDefaultMipMap (bool mipMap) = 0;
  virtual bool IsDefaultMipMap () const = 0;

  virtual void SetDefaultFilter (ceFilter filter) = 0;
  virtual ceFilter GetDefaultFilter () const = 0;

  virtual void SetDefaultWrapMode (ceWrapMode wrapMode) = 0;
  virtual ceWrapMode GetDefaultWrapMode () const = 0;

  /**
   * @}
   */

	virtual void SetEffectTechnique (iEffectTechnique* technique) = 0;
	virtual iEffectTechnique* GetEffectTechnique () const = 0;

  virtual void SetProgram (iProgram* program) = 0;
  virtual iProgram* GetProgram () const = 0;

  virtual void ClearShadowMap (unsigned i) = 0;
  virtual void SetShadowMap (unsigned i, iTexture* shadowMap, const ceMatrix4f& view, const ceMatrix4f& projection) = 0;

  virtual void SetShadowOverlayer (iTexture* shadowOverlayer) = 0;


  virtual void SetUseBlend(bool useBlend) = 0;

  virtual void SetMaterial (ceMaterialSpec* material) = 0;
  virtual void SetLight (ceLight* light) = 0;

  virtual void ClearTextures () = 0;
  virtual void SetTexture (ceTextureStage stage, iTexture* texture) = 0;
  virtual iTexture* GetTexture (ceTextureStage stage) = 0;

  virtual void SetProjectionMatrix (const ceMatrix4f& matrix) = 0;
  virtual void SetViewMatrix (const ceMatrix4f& matrix) = 0;
  virtual void SetModelMatrix (const ceMatrix4f& matrix) = 0;

  virtual bool BeginPass (ceRenderPass pass) = 0;
  virtual void EndPass (ceRenderPass pass) = 0;

  virtual void SetVertexDeclaration (iVertexDeclaration* vertexDeclaration) = 0;
  virtual void SetStreamSource (unsigned stream, iVertexBuffer* buffer) = 0;

  virtual void SetRenderTarget (iRenderTarget* renderTarget) = 0;

  virtual void ApplyShaderStates (ceSharedShaderBinding* bindings = 0) = 0;
  virtual void SetIndices(iIndexBuffer* indices) = 0;
  virtual void DrawPrimitives(cePrimitiveType type, unsigned first, unsigned count, bool unbind = true) = 0;
  virtual void DrawIndexPrimitives(cePrimitiveType pType, ceDataType iType, unsigned primCount, bool unbind = true) = 0;
  virtual void DrawIndexPrimitivesInstanced(cePrimitiveType pType, ceDataType iType, unsigned primCount, unsigned instanceCount, bool unbind = true) = 0;
  virtual void RedrawPrimitives (bool unbind = false) = 0;
  virtual void RedrawIndexPrimitives (bool unbind = false) = 0;
  virtual void DrawBoundingBox (const ceBoundingBox& bbox) = 0;
  virtual void DrawRect (const ceRect& rect) = 0;
  virtual void SetViewport (const iViewport* viewport) = 0;
  virtual void SetViewport (const ceRect& viewport) = 0;
  virtual void SetCamera (const ceCamera& camera) = 0;
  virtual void SetProjector (const ceProjector& projector) = 0;
  virtual void Clear (bool clearColor = true, const ceColor4f& color = ceColor4f(0, 0, 0, 1), bool clearDepth = true, float depth = 1.0f, bool clearStencil = false, unsigned stencil = 0) = 0;


};

/** @} */

#endif /* ! __CE_GFX_IDEVICE_H__ */

